package com.david.trade.clear;

import com.david.trade.clear.component.RingBufferComponent;
import com.david.trade.clear.component.TcpMessageEventHandler;
import com.david.trade.clear.tcp.ServerInitializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
public class ClearApplication {

    public static void main(String[] args) {
        SpringApplication sa = new SpringApplication(ClearApplication.class);
        sa.run(args);
        ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
        ServerInitializer serverInitializer = applicationContext.getBean(ServerInitializer.class);
        serverInitializer.start(6543);

        TcpMessageEventHandler tcpMessageEventHandler = new TcpMessageEventHandler();
        RingBufferComponent.ringBufferComponent = new RingBufferComponent((int) Math.pow(2, 10), tcpMessageEventHandler);
        RingBufferComponent.ringBufferComponent.start();

    }

}
